package com.cctv.order.controller;

import com.cctv.order.dto.OrderDTO;
import com.cctv.order.message.StreamClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Author: cctv
 * @Date: 2019/6/11 11:31
 */
@RestController
public class SendMessageController {
    @Autowired
    private StreamClient streamClient;

    @GetMapping("/sendMessage")
    public void process() {
//        String message = "now " + new Date();
//        streamClient.output().send(MessageBuilder.withPayload(message).build());
        OrderDTO orderDTO = new OrderDTO();
        orderDTO.setOrderId("123456789");
        streamClient.input().send(MessageBuilder.withPayload(orderDTO).build());

    }
}
